package com.szewec.ps.myview.album;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;

import com.szewec.ps.R;
import com.szewec.ps.util.imagepicker.view.SquareImageView;

public class AlbumItemViewHolder extends RecyclerView.ViewHolder{
    private boolean isEdit = false;
    private boolean isVideo = false;
    private boolean isAdd = false;

    private View rootView;
    //正方形图片
    public SquareImageView mImageView;
    //删除按钮
    private ImageView mImageDelete;
    //播放布局
    ConstraintLayout playConstraintLayout;
    //照相机布局
    ConstraintLayout cameraConstraintLayout;
    //描述编辑框
    EditText etdescripyion;
    AlbumItemViewHolder(@NonNull final View view) {
        super(view);
        rootView = view;
        mImageDelete = view.findViewById(R.id.iv_delete_item);
        mImageView = view.findViewById(R.id.siv_item_image);
        playConstraintLayout = view.findViewById(R.id.cl_video_play);
        cameraConstraintLayout = view.findViewById(R.id.cl_camera);
        etdescripyion = view.findViewById(R.id.et_description);
        //如果状态为查看，则隐藏删除按钮
        if(isEdit){
            mImageDelete.setVisibility(View.VISIBLE);
            etdescripyion.setVisibility(View.VISIBLE);
        }
        //如果是视频显示，时长和播放按钮
        if(isVideo){
            playConstraintLayout.setVisibility(View.VISIBLE);
        }
//        if(isAdd){
//            cameraConstraintLayout.setVisibility(View.VISIBLE);
//        }
    }

    public boolean isEdit() {
        return isEdit;
    }

    public void setEdit(boolean edit) {
        isEdit = edit;
        if(isEdit){
            mImageDelete.setVisibility(View.VISIBLE);
            etdescripyion.setVisibility(View.VISIBLE);
        }else{
            mImageDelete.setVisibility(View.GONE);
        }
    }

    public boolean isVideo() {
        return isVideo;
    }

    public void setVideo(boolean video) {
        isVideo = video;
        if(isVideo){
            playConstraintLayout.setVisibility(View.VISIBLE);
        }else{
            playConstraintLayout.setVisibility(View.GONE);
        }
    }

    public boolean isAdd() {
        return isAdd;
    }

    public void setAdd(boolean add) {
        isAdd = add;
        if (isAdd){
            etdescripyion.setVisibility(View.GONE);
        }else{
            etdescripyion.setVisibility(View.VISIBLE);
        }
    }

    public View getRootView() {
        return rootView;
    }

    public void setRootView(View rootView) {
        this.rootView = rootView;
    }


    public SquareImageView getmImageView() {
        return mImageView;
    }

    public void setmImageView(SquareImageView mImageView) {
        this.mImageView = mImageView;
    }

    public ImageView getmImageDelete() {
        return mImageDelete;
    }

    public void setmImageDelete(ImageView mImageDelete) {
        this.mImageDelete = mImageDelete;
    }
    public ConstraintLayout getPlayConstraintLayout() {
        return playConstraintLayout;
    }

    public void setPlayConstraintLayout(ConstraintLayout playConstraintLayout) {
        this.playConstraintLayout = playConstraintLayout;
    }

    public ConstraintLayout getCameraConstraintLayout() {
        return cameraConstraintLayout;
    }

    public void setCameraConstraintLayout(ConstraintLayout cameraConstraintLayout) {
        this.cameraConstraintLayout = cameraConstraintLayout;
    }

    public EditText getEtdescripyion() {
        return etdescripyion;
    }

    public void setEtdescripyionText(String descripyion) {
        this.etdescripyion.setText(descripyion);
    }
}

